<?php
class Car{
    public $color;
    public $userName;
    public function use()
    {
        echo "我是机动车";
    }
    public function __construct($color,$username)
    {
        $this->color=$color;
        $this->userName=$username;
    }
    public function equals($obj1,$obj2){
        if(($obj1->color==$obj2->color) && ($obj1->userName==$obj2->userName)){
            echo "相等";
        }else{
            echo "不想等";
        }
    }
    
}
class Taxi extends Car{
    public $company;
    public function __construct($color,$username,$company)
    {
        $this->company=$company;
        parent::__construct($color,$username);
    }
    public function use(){
        echo "出租⻋是提⾼市⺠⽣活质量的重要条件之⼀";
    }
    public function toString(){
        echo $this->color,$this->userName;
    }
    final function ride(){
        echo $this->userName."出租⻋是所属于在".$this->company."公司的";
    }
}
class HomeCar extends Car{
    public $num;
    public function __construct($color,$username,$num)
    {
        $this->color=$color;
        $this->userName=$username;
        $this->num=$num;
    }
    public function display(){
        echo $this->userName."拥有的".$this->color."颜⾊的私家⻋有".$this->num."座位";
    }
    public function display1($num){
        echo "家⽤汽⻋⼤多有".$this->num;
    }
}
$car=new Car('红色','小明');
$car1=new Car('红色','小明');
var_dump($car);
echo '<br/>';

$car->use();
echo '<br/>';

$car->equals($car,$car1);
echo '<br/>';

$taxi=new Taxi('蓝色','小芳','保护力');
$taxi->toString();
echo '<br/>';

$taxi->ride();
echo '<br/>';

$HomeCar=new HomeCar('蓝色','小芳',8);
// var_dump($HomeCar);
$HomeCar->display();
?>